{% set packages = (python.packages is defined) ? python.packages : [] %}

<input type="hidden" name="python[install]" value="1" />

<div class="container-fluid cm-container-white section-title">
    <h1>Python</h1>

    <p>Configure Python versions and packages</p>
</div>

<div id="python-container"
     class="container-fluid collapse in">
    <div class="panel panel-default">
        <div class="panel-body">
            <div class="help-block col-xs-12">
                <p>Ubuntu comes with <code>Python 2.7</code>,
                    and CentOS comes with <code>Python 2.6</code> out of the box.</p>
                <p>Any extra Python versions you choose will be installed using
                    <a href="https://github.com/yyuu/pyenv" target="_blank">pyenv</a>
                    as system installations, <em>not user installations</em>.</p>
                <p>All extra Python versions require compiling. Choose sparingly - each
                    additional version will add extra time to the initial
                    <code>$ vagrant up</code>!</p>
                <p>At least one Python version must be installed to install packages via
                    <code>pip</code>!</p>
            </div>

            <div class="clearfix"></div>

            <div class="form-group col-xs-12 col-sm-6">
                <label for="python-packages">
                    Install Packages
                </label>
                <select id="python-packages"
                        name="python[packages][]"
                        multiple class="form-control select-tags-editable">
                    {% for package in packages %}
                        <option selected value="{{ package }}">{{ package }}</option>
                    {% endfor %}
                </select>
                <div class="help-block">
                    <p>To install a specific package version, use <code>{package}@{version}</code>.</p>
                    <p>eg: <code>Django@1.6.5</code>. For latest just use <code>{package}</code>.</p>
                    <p><a href="https://pypi.python.org/pypi"
                          target="_blank">All valid Packages list</a>.</p>
                </div>
            </div>
        </div>
    </div>

    <div class="clearfix"></div>

    <div class="panel panel-primary">
        <div class="panel-heading">Versions</div>
        <div class="panel-body">
            <ul class="nav nav-tabs nested-tabs sortable">
                <li class="add">
                    <a href="{{ path('puphpet.python.add_version') }}"
                       data-toggle="add-block">
                        <i class="fa fa-plus"></i> Add</a>
                </li>
                {% for index, selected_version in python.versions %}
                    {% set blockId = "python-versions-#{index}" %}
                    {% set blockName = "python[versions][#{index}]" %}
                    <li class="{{ loop.first ? 'active' }}">
                        <a href="#" data-target="#{{ blockId }}"
                           data-toggle="tab">{{ index }}</a>
                        <div class="btn-group">
                            <button type="button" class="btn btn-default"
                                    data-toggle="delete-block"
                                    data-target="#{{ blockId }}">
                                <i class="fa fa-close"></i></button>
                        </div>
                        <input type="hidden" name="{{ blockName }}" value="1" />
                    </li>
                {% endfor %}
            </ul>

            <div class="tab-content">
                <div class="empty-tabs">
                    <i class="fa fa-share fa-rotate-270" aria-hidden="true"></i>
                    Click to add a Python version
                </div>
                {% for index, selected_version in python.versions %}
                    {% include 'PuphpetBundle:python:version.html.twig' with {
                        'available_versions': python.available.versions,
                        'selected_version': selected_version,
                        'uniqid': index,
                        'active': loop.first ? true : false,
                    } %}
                {% endfor %}
            </div>
        </div>
    </div>

    <div class="clearfix"></div>
</div>

<div class="container-fluid cm-container-white section-footer">
    <a href="#ruby" data-toggle="tab" class="btn btn-primary btn-lg pull-left">
        <i class="fa fa-arrow-left" aria-hidden="true"></i>
        Ruby
    </a>

    <a href="#nodejs" data-toggle="tab" class="btn btn-primary btn-lg pull-right">
        Node.js
        <i class="fa fa-arrow-right" aria-hidden="true"></i>
    </a>
</div>
